home *** CD-ROM | disk | FTP | other *** search
/ System Booster / System Booster.iso / Texteditors / XDME / Src / Var / SmallSPC.c < prev    next >
C/C++ Source or Header  |  1996-09-26  |  18KB  |  812 lines

  1. /******************************************************************************
  2.  
  3.     MODUL
  4.     smallspc.c
  5.  
  6.     DESCRIPTION
  7.     minimal interface for special variables
  8.     setting and reading
  9.  
  10.     NOTES
  11.     look into future/...
  12.  
  13.     BUGS
  14.     none known
  15.  
  16.     TODO
  17.     entries for all new spcvars
  18.     join the 3 functions into 1
  19.     create a list that is scanned in a loop
  20.  
  21.     EXAMPLES
  22.  
  23.     SEE ALSO
  24.     vars.c
  25.  
  26.     INDEX
  27.  
  28.     HISTORY
  29.     21 Nov 92 null created
  30.     28-07-94 null added "$version"
  31.  
  32. *!***************************************************************************
  33. *!
  34. *!  Special Variables - Overview
  35. *!
  36. *!  these are some builtin variables, which represent some
  37. *!  more or less important things in XDME's interna
  38. *!  since some of them are build via functions, not each of them
  39. *!  is writable through the variable interface; however all of them
  40. *!  should be readable via the variable interface
  41. *!
  42. *! this is the list of the currently supported Special variables
  43. *!
  44. *!    ascii
  45. *!    autoindent
  46. *!    autosplit
  47. *!    autounblock
  48. *!    activetofront
  49. *!    bgpen
  50. *!    bbpen
  51. *!    colno
  52. *!    currentline
  53. *!    currentword
  54. *!    cursorpen
  55. *!    debug
  56. *!    fgpen
  57. *!    filename
  58. *!    findstr
  59. *!    fname
  60. *!    fpath
  61. *!    globalsearch
  62. *!    hgpen
  63. *!    ignorecase
  64. *!    infixmode
  65. *!    insertmode
  66. *!    keytable
  67. *!    lineno
  68. *!    margin
  69. *!    menustrip
  70. *!    modified
  71. *!    parcol
  72. *!    qualifiers
  73. *!    refpaths
  74. *!    repstr
  75. *!    restofline
  76. *!    rexxport
  77. *!    savetabs
  78. *!    scanf
  79. *!    tabstop
  80. *!    textnames
  81. *!    tpen
  82. *!    viewmode
  83. *!    wordwrap
  84. *!    windowcycling
  85. *!    version
  86. *!
  87. ******************************************************************************/
  88.  
  89. /**************************************
  90.         Includes
  91. **************************************/
  92. #include "defs.h"
  93.  
  94. /**************************************
  95.         Globale Variable
  96. **************************************/
  97. Prototype char* GetSpecialVar (char* Name);
  98. Prototype char* GetSpecialInt (char* Name);
  99. Prototype char* GetSpecialFlag(char* Name);
  100.  
  101. Prototype char SetSpecialFlag(char* Name, char* Value);
  102. Prototype char SetSpecialInt (char* Name, char* Value);
  103. Prototype char SetSpecialVar (char* Name, char* Value);
  104.  
  105. Prototype void do_togglespecialflag(void);
  106. Prototype void do_setspecialvar(void);
  107.  
  108. extern UBYTE Fstr[];
  109. extern UBYTE Rstr[];
  110.  
  111. /**************************************
  112.       Interne Defines & Strukturen
  113. **************************************/
  114.     const char* N_ascii     = "ascii";
  115.     const char* N_autoindent    = "autoindent";
  116.     const char* N_autosplit    = "autosplit";
  117.     const char* N_autounblock    = "autounblock";
  118.     const char* N_activetofront = "activetofront";
  119.     const char* N_bgpen     = "bgpen";
  120.     const char* N_bbpen     = "bbpen";
  121.     const char* N_colno     = "colno";
  122.     const char* N_currentline    = "currentline";
  123.     const char* N_currentword    = "currentword";
  124.     const char* N_cursorpen    = "cursorpen";
  125.     const char* N_debug     = "debug";
  126.     const char* N_fgpen     = "fgpen";
  127.     const char* N_filename    = "filename";
  128.     const char* N_findstr    = "findstr";
  129.     const char* N_fname     = "fname";
  130.     const char* N_fpath     = "fpath";
  131.     const char* N_globalsearch    = "globalsearch";
  132.     const char* N_hgpen     = "hgpen";
  133.     const char* N_ignorecase    = "ignorecase";
  134.     const char* N_infixmode    = "infixmode";
  135.     const char* N_insertmode    = "insertmode";
  136.     const char* N_keytable    = "keytable";
  137.     const char* N_lineno    = "lineno";
  138.     const char* N_margin    = "margin";
  139.     const char* N_menustrip    = "menustrip";
  140.     const char* N_modified    = "modified";
  141.     const char* N_parcol    = "parcol";
  142.     const char* N_qualifiers    = "qualifiers";
  143.     const char* N_refpaths    = "refpaths";
  144.     const char* N_repstr    = "repstr";
  145.     const char* N_restofline    = "restofline";
  146.     const char* N_rexxport    = "rexxport";
  147.     const char* N_savetabs    = "savetabs";
  148.     const char* N_scanf     = "scanf";
  149.     const char* N_tabstop    = "tabstop";
  150.     const char* N_textnames    = "textnames";
  151.     const char* N_tpen        = "tpen";
  152.     const char* N_viewmode    = "viewmode";
  153.     const char* N_wordwrap    = "wordwrap";
  154.     const char* N_windowcycling = "windowcycling";
  155.     const char* N_version    = "version";
  156.  
  157.  
  158. /**************************************
  159.         Interne Variable
  160. **************************************/
  161.  
  162.  
  163. /**************************************
  164.        Interne Prototypes
  165. **************************************/
  166. Prototype char* current_word (void);
  167.  
  168.  
  169. /*
  170. **  GetSpecialVar - Get one of the internal special String Vars:
  171. **
  172. **  >name == the name of the variable to search for
  173. **  <ptr to malloced string
  174. **  <NULL == not found or error
  175. */
  176.  
  177. char*
  178. GetSpecialVar(char* Name)
  179. {
  180.     int i,j;
  181.     char* str;        /* return */
  182.     char* ptr;        /* help: if not NULL, anything was found */
  183.  
  184.     str = NULL;
  185.     ptr = NULL;
  186.     i = 0;
  187.     j = 0;
  188. /* printf("Vn=%s\n",Name); */
  189.  
  190.     if ((Name == NULL) || (Name[0] == 0))
  191.     {
  192.     return(NULL);
  193.     } /* if */
  194.                     /* String Variables */
  195.  
  196.     switch (Name[0])
  197.     {
  198.     case 'c':
  199.     if (strcmp (Name, N_currentline) == 0)
  200.     { /* old */
  201.         ptr = Current;
  202.     } else
  203.     if (strcmp (Name, N_currentword) == 0)
  204.     { /* new */
  205.         ptr = current_word();
  206.     } /* if */
  207.     break;
  208.     case 'f':
  209.     if (strcmp (Name, N_filename) == 0)
  210.     {    /* old */
  211.         ptr = Ep->name;
  212.     } else
  213.     if (strcmp (Name, N_fname) == 0)
  214.     {    /* old */
  215.         ptr = fname(Ep->name);
  216.     } else
  217.     if (strcmp (Name, N_findstr) == 0)
  218.     {     /* old */
  219.         ptr = Fstr;
  220.     } /* if */
  221.     break;
  222.  
  223.     case 'k':                                   /* PATCH_NULL [01 Feb 1993] : added */
  224.     if (strcmp (Name, N_keytable) == 0)
  225.     {
  226.         if (ptr = currenthash()) {
  227.         ptr = ((struct Node *)ptr)->ln_Name;
  228.         } /* if */
  229.     } /* if */
  230.     break;
  231.     case 'm':                                   /* PATCH_NULL [01 Feb 1993] : added */
  232.     if (strcmp (Name, N_menustrip) == 0)
  233.     {
  234.         if (ptr = currentmenu()) {
  235.         ptr = ((struct Node *)ptr)->ln_Name;
  236.         } /* if */
  237.     } /* if */
  238.     break;
  239.     case 'r':
  240.     if (strcmp (Name, N_repstr) == 0)
  241.     {      /* old */
  242.         ptr = Rstr;
  243.     } else
  244.     if (strcmp (Name, N_restofline) == 0)
  245.     {
  246.         if (Clen>=Ep->column) {
  247.         ptr = Current + Ep->column;        /* DANGER */
  248.         } else {
  249.         ptr = Current + Clen;
  250.         } /* if */
  251.     } /* if */
  252.     break;
  253.     case 's':
  254.     if (strcmp (Name, N_scanf) == 0)
  255.     {    /* old */
  256.         ptr = String;
  257.     } /* if */
  258.     break;
  259.     case 'v':
  260.     if (strcmp (Name, N_version) == 0)
  261.     {    /* old */
  262.         ptr = version;
  263.     } /* if */
  264.     break;
  265.  
  266.     default:
  267.     break;
  268.     } /* switch */
  269.  
  270.     if (ptr != NULL)
  271.     {
  272.     str = malloc (strlen(ptr)+1);
  273.     if (str)
  274.     {
  275.         strcpy(str, ptr);
  276.         return(str);
  277.     } else if (*ptr != 0)
  278.     {
  279.         nomemory();
  280.         abort(NULL);
  281.     } else
  282.     {
  283.         return(str);
  284.     } /* if */
  285.     } /* if */
  286.  
  287.     return(NULL);
  288. } /* GetSpcVar */
  289.  
  290.  
  291. /*
  292. **  SetSpecialVar - set one of DME's internal special String vars
  293. **
  294. **  >Name  - name of the variable to modify
  295. **  >Value - new value of the variable
  296. **  <0 == name not found
  297. **  <1 == ok ( also if variable is readonly )
  298. */
  299.  
  300. char
  301. SetSpecialVar(char* Name, char* Value)
  302. {
  303.     char* ptr;
  304.     int len;
  305.  
  306.     if ((Name == NULL) || (Name[0] == 0))
  307.     {
  308.     return(0);
  309.     } /* if */
  310.     ptr = NULL;
  311.     len = LINE_LENGTH;
  312.  
  313. /* printf("Vs=%s\n",Name); */
  314.  
  315.     if (strcmp (Name, N_filename) == 0)
  316.     {
  317.         ptr = Ep->name;
  318.         len = 63;
  319.     } else
  320.  
  321.     if (strcmp (Name, N_findstr) == 0)
  322.     {
  323.         ptr = Fstr;
  324.     } else
  325.     if (strcmp (Name, N_repstr) == 0)
  326.     {
  327.         ptr = Rstr;
  328.     } else
  329.     if (strcmp (Name, N_scanf) == 0)
  330.     {
  331.         ptr = String;
  332.     } else
  333.     if (strcmp (Name, N_currentline) == 0)
  334.     {
  335.         abort(1);
  336.     } else
  337.     if (strcmp (Name, N_currentword) == 0)
  338.     {
  339.         abort(1);
  340.     } else
  341.     if (strcmp (Name, N_version) == 0)
  342.     {
  343.         abort(1);
  344.     } else
  345.     if (strcmp (Name, N_restofline) == 0)
  346.     {
  347.         abort(1);
  348.     } /* if */
  349.  
  350.     if (ptr)
  351.     {
  352.     strncpy(ptr, Value, len);
  353.     return(1);  /* found */
  354.     } else
  355.     return(0);  /* not found */
  356. } /* SetSpecialVar */
  357.  
  358.  
  359.  
  360. /*
  361. **  GetSpecialInt - Get one of the internal special Integer Vars:
  362. **
  363. **  >name == the name of the variable to search for
  364. **  <ptr to malloced string
  365. **  <NULL == not found or error
  366. */
  367.  
  368. char*
  369. GetSpecialInt(char* Name)
  370. {
  371.     int found;
  372.     long i;
  373.     char* str;        /* return */
  374.     char buffer[16];    /* help: convert numbers here */
  375.  
  376.     found = 0;
  377. /* printf("In=%s\n",Name); */
  378.  
  379.     if (strcmp (Name, N_ascii) == 0)
  380.     { /* current char */
  381.         i = Current[Ep->column];
  382.         found = 1;
  383.     } else
  384.     if (strcmp (Name, N_bbpen) == 0)
  385.     { /* highlight pen */
  386.         i = BLOCK_BPEN;
  387.         found = 1;
  388.     } else
  389.     if (strcmp (Name, N_bgpen) == 0)
  390.     { /* background pen */
  391.         i = TEXT_BPEN;
  392.         found = 1;
  393.     } else
  394.     if (strcmp (Name, N_colno) == 0)
  395.     { /* current xpos */
  396.         i = Ep->column + 1;
  397.         found = 1;
  398.     } else
  399.     if (strcmp (Name, N_fgpen) == 0)
  400.     { /* foreground pen */
  401.         i = TEXT_FPEN;
  402.         found = 1;
  403.     } else
  404.     if (strcmp (Name, N_hgpen) == 0)
  405.     { /* highlight pen */
  406.         i = BLOCK_FPEN;
  407.         found = 1;
  408.     } else
  409.     if (strcmp (Name, N_lineno) == 0)
  410.     { /* current ypos */
  411.         i =  Ep->line + 1;
  412.         found = 1;
  413.     } else
  414.     if (strcmp (Name, N_margin) == 0)
  415.     { /* right margin for wordwrap */
  416.         i = Ep->config.margin;
  417.         found = 1;
  418.     } else
  419.     if (strcmp (Name, N_parcol) == 0)
  420.     { /* left margin of paragraph? */
  421.         i = Ep->config.wwcol;
  422.         found = 1;
  423.     } else
  424.     if (strcmp (Name, N_tpen) == 0)
  425.     { /* title bar rendering */
  426.         i = TITLE_BPEN;
  427.         found = 1;
  428.     } else
  429.     if (strcmp (Name, N_tabstop) == 0)
  430.     {
  431.         i = Ep->config.tabstop;
  432.         found = 1;
  433.     } /* if */
  434.  
  435.  
  436.     if (found)
  437.     {
  438.     sprintf(buffer,"%ld",i);
  439.     str = malloc(strlen(buffer)+1);
  440.     if (str)
  441.     {
  442.         strcpy(str, buffer);
  443.         return(str);
  444.     } else
  445.     {
  446.         nomemory();
  447.         abort(NULL);
  448.     } /* if */
  449.     } /* if */
  450.     return(NULL);
  451. } /* GetSpecialInt */
  452.  
  453.  
  454.  
  455. /*
  456.  *  GetSpecialFlag - Get one of the internal special Flags:
  457.  *
  458.  *  >name == the name of the variable to search for
  459.  *  <ptr to malloced string
  460.  *  <NULL == not found or error
  461.  */
  462.  
  463. char*
  464. GetSpecialFlag(char* Name)
  465. {
  466.     char i,found;
  467.     char* str;        /* return */
  468.     char buffer[4];    /* help: convert numbers here */
  469.  
  470. /* printf("Fn=%s\n",Name); */
  471.     found = 0;
  472.                             /* locals */
  473.     if (strcmp (Name, N_autounblock) == 0)
  474.     {
  475.         i = Ep->config.autounblock ? 1 : 0;
  476.         found = 1;
  477.     } else
  478.     if (strcmp (Name, N_autoindent) == 0)
  479.     {
  480.         i = Ep->config.autoindent ? 1 : 0;
  481.         found = 1;
  482.     } else
  483.     if (strcmp (Name, N_autosplit) == 0)
  484.     {
  485.         i = Ep->config.autosplit ? 1 : 0;
  486.         found = 1;
  487.     } else
  488.     if (strcmp (Name, N_debug) == 0)
  489.     {
  490.         i = globalflags.debug ? 1 : 0;
  491.         found = 1;
  492.     } else
  493.     if (strcmp (Name, N_infixmode) == 0)
  494.     {  /* while searching */
  495.         i = Ep->config.ignorecase ? 1 : 0;
  496.         found = 1;
  497.     } else
  498.     if (strcmp (Name, N_insertmode) == 0)
  499.     {  /* <-> overwrite */
  500.         i = Ep->config.insertmode ? 1 : 0;
  501.         found = 1;
  502.     } else
  503.     if (strcmp (Name, N_modified) == 0)
  504.     {    /*  */
  505.         i = Ep->modified ? 1 : 0;
  506.         found = 1;
  507.     } else
  508.     if (strcmp (Name, N_viewmode) == 0)
  509.     {
  510.         i = Ep->viewmode ? 1 : 0;
  511.         found = 1;
  512.     } else
  513.     if (strcmp (Name, N_wordwrap) == 0)
  514.     {
  515.         i = Ep->config.wordwrap ? 1 : 0;
  516.         found = 1;
  517.     } else
  518.  
  519.                             /* globals */
  520.     if (strcmp (Name, N_activetofront) == 0)
  521.     {
  522.         i = globalflags.ActivateToFront ? 1 : 0;
  523.         found = 1;
  524.     } else
  525.     if (strcmp (Name, N_globalsearch) == 0)
  526.     {
  527.         i = globalflags.global_search ? 1 : 0;
  528.         found = 1;
  529.     } else
  530.     if (strcmp (Name, N_infixmode) == 0)
  531.     {   /* <-> prefixmode / math2 */
  532.         i = MathInfix ? 1 : 0;
  533.         found = 1;
  534.     } else
  535.     if (strcmp (Name, N_savetabs) == 0)
  536.     {
  537.         i = globalflags.Savetabs ? 1 : 0;
  538.         found = 1;
  539.     } else
  540.     if (strcmp (Name, N_windowcycling) == 0)
  541.     {
  542.         i = globalflags.Windowcycling ? 1 : 0;
  543.         found = 1;
  544.     /* aborted */
  545.     } /* if */
  546.  
  547.     if (found)
  548.     {
  549.     sprintf(buffer,"%ld",i);
  550.     if (str = strdup(buffer))
  551.     {
  552.         return(str);
  553.     } else
  554.     {
  555.         nomemory();
  556.         abort(NULL);
  557.     } /* if */
  558.     } /* if */
  559.     return(NULL);
  560. } /* GetSpecialFlag */
  561.  
  562.  
  563.  
  564. /*
  565.  *  SetSpecialInt - Set a special Integer variable
  566.  *
  567.  *  >Name  - name of the variable to modify
  568.  *  >value - new value of the variable
  569.  *  <0 == name not found or value was no integer
  570.  *  <1 == name found (also if variable is write only)
  571.  */
  572.  
  573. char
  574. SetSpecialInt(char* name, char* value)
  575. {
  576.     int   val;
  577. //    char found = 0;
  578.  
  579. /* printf("Is=%s\n",name); */
  580.     if (!is_number(value))
  581.     {  /* --- that is not correct but easy */
  582.     return(0);
  583.     } /* if */
  584.     val = atoi(value);
  585.  
  586.  
  587.     if ((strcmp (name, N_bgpen) == 0) ||
  588.       (strcmp (name, N_colno) == 0) ||
  589.       (strcmp (name, N_lineno) == 0) ||
  590.       (strcmp (name, N_fgpen) == 0) ||
  591.       (strcmp (name, N_hgpen) == 0) ||
  592.       (strcmp (name, N_tpen) == 0))
  593.       {
  594.         abort(1);
  595.     } else
  596.     if (strcmp (name, N_ascii) == 0)
  597.     {
  598.         if (!Ep->viewmode)
  599.         {
  600.         Current[Ep->column] = val / LINE_LENGTH;
  601.         } /* if */
  602.     } else
  603.     if (strcmp (name, N_margin) == 0)
  604.     {
  605.         Ep->config.margin = val % (LINE_LENGTH);
  606.     } else
  607.     if (strcmp (name, N_parcol) == 0)
  608.     {
  609.         Ep->config.wwcol = val % (LINE_LENGTH);
  610.     } else
  611.     if (strcmp (name, N_tabstop) == 0)
  612.     {
  613.         Ep->config.tabstop = val % (LINE_LENGTH);
  614.     } else
  615.     {
  616.         return(0);  /* not found */
  617.     } /* if */
  618.     return(1);      /* found */
  619. } /* SetSpecialInt */
  620.  
  621.  
  622.  
  623. /*
  624.  *  SetSpecialFlag - Set a specialFlag
  625.  *
  626.  *  >Name  - name of the variable to modify
  627.  *  >value - new value of the variable
  628.  *  <0 == name not found
  629.  *  <1 == ok ( also if other error)
  630.  */
  631.  
  632. char
  633. SetSpecialFlag(char* name, char* value)
  634. {
  635.     char* charptr;
  636.     char* comment;
  637.     char  buffer[32];
  638.     char* com[2];
  639.  
  640.     charptr = NULL;
  641.     comment = NULL;
  642.     com[0]  = "Off";
  643.     com[1]  = "On";
  644.  
  645. #define ChangeBitFlag(name,comment)                                 \
  646.     {                                    \
  647.     Ep->config. name = test_arg (value, Ep->config. name );     \
  648.     sprintf(buffer,"%s %s ", comment, com[Ep->config. name ]);  \
  649.     title(buffer);                                              \
  650.     return(1);                                                  \
  651.     }
  652.  
  653.     /* printf("Fs=%s\n",name); */
  654.     /* --- local flags */
  655.  
  656.     if (strcmp (name, N_autounblock) == 0)
  657.     ChangeBitFlag(autounblock,"Autounblock")
  658.     else if (strcmp (name, N_autoindent) == 0)
  659.     ChangeBitFlag(autoindent,"Autoindent")
  660.     else if (strcmp (name, N_autosplit) == 0)
  661.     ChangeBitFlag(autosplit,"Autosplit")
  662.     else if (strcmp (name, N_ignorecase) == 0)
  663.     {    /* search case <-> ignorecase */
  664.     com[0]    = "Sensitive";
  665.     com[1]    = "InSensitive";
  666.     ChangeBitFlag(ignorecase,"Case")
  667.     }
  668.     else if (strcmp (name, N_insertmode) == 0)
  669.     /* <-> overwrite text */
  670.     ChangeBitFlag(insertmode,"Inset Mode")
  671.     else if (strcmp (name, N_wordwrap) == 0)
  672.     ChangeBitFlag(wordwrap,"Wordwrap")
  673.  
  674.     /* editor-specific flags */
  675. #undef ChangeBitFlag
  676. #define ChangeBitFlag(name,comment)                                 \
  677.     {                                    \
  678.     Ep-> name = test_arg (value, Ep-> name);                    \
  679.     sprintf(buffer,"%s %s ",comment, com[Ep-> name]);           \
  680.     title(buffer);                                              \
  681.     return(1);                                                  \
  682.     }
  683.  
  684.     else if (strcmp (name, N_viewmode) == 0)
  685.     ChangeBitFlag(viewmode,"Viewmode")
  686.     else if (strcmp (name, N_modified) == 0)
  687.     ChangeBitFlag(modified,"Modified")
  688.  
  689.     /* --- global flags */
  690. #undef ChangeBitFlag
  691. #define ChangeBitFlag(name,comment)                                 \
  692.     {                                    \
  693.     globalflags.name = test_arg (value, globalflags.name);      \
  694.     sprintf(buffer,"%s %s ",comment, com[globalflags.name]);     \
  695.     title(buffer);                                              \
  696.     return(1);                                                  \
  697.     }
  698.  
  699.     else if (strcmp (name, N_activetofront) == 0)
  700.     ChangeBitFlag(ActivateToFront,"Moving Activated Windows To Front")
  701.     else if (strcmp (name, N_debug) == 0)
  702.     ChangeBitFlag(debug,"Debugging mode")
  703.     else if (strcmp (name, N_globalsearch) == 0)
  704.     ChangeBitFlag(global_search,"Global Searching")
  705.     else if (strcmp (name, N_savetabs) == 0)
  706.     /* save tabs or whitespaces */
  707.     ChangeBitFlag(Savetabs,"Save tabs")
  708.     else if (strcmp (name, N_windowcycling) == 0)
  709.     ChangeBitFlag(Windowcycling,"Windowcycling")
  710.  
  711. #undef ChangeBitFlag
  712.  
  713.     return(0);     /* not found */
  714. } /* SetSpecialFlag */
  715.  
  716.  
  717.  
  718. /*
  719.  *    This function is to be called for all toggling any special flag
  720.  *    via a command:        flagname mode
  721.  *  The only thing is - the variable must be treated here
  722.  */
  723.  
  724. void
  725. do_togglespecialflag()
  726. {
  727.     if (!SetSpecialFlag(av[0],av[1]))
  728.     abort2();
  729. } /* do_togglespecialflag */
  730.  
  731.  
  732.  
  733. /*
  734.  *    This function might be called for all setting any special var
  735.  *    via a command:        varname mode
  736.  *  The only thing is - the variable must be treated here
  737.  */
  738.  
  739. void
  740. do_setspecialvar()
  741. {
  742.     if ( !SetSpecialInt(av[0],av[1])
  743.       && !SetSpecialVar(av[0],av[1]) )
  744.     abort2();
  745. } /* do_setspecialvar */
  746.  
  747.  
  748. /*
  749. **  Redefine these names to adjust the used buffers to Your settings
  750. **  the commands are 'atomic' so there should be no interference to
  751. **  other 'atomic' commands using them.
  752. **
  753. **  for XDME changed buffers[0]/buffers[1] to tmp_buffer/tmp_buf2
  754. */
  755. #define firstbuffer  tmp_buffer
  756.  
  757.  
  758.  
  759.  
  760. /*
  761. * !  $[SPC.]currentword
  762. * !     that read-only special-variable
  763. * !     represents "the word under the cursor"
  764. * !     that means it finds the beginning of the current word on
  765. * !     on its own (but we do not move the cursor) if cursor is
  766. * !     not within a word, it returns the next word of the line
  767. * !     if there is no next word, an empty string is returned
  768. * !  NOTE this variable is not accessible, if PATCH_VARS is not active
  769. * !
  770. **  current_word           (uses firstbuffer)
  771. **
  772. **  Returns the word under the cursor,
  773. **  is used by fastscan and should be used by ref and tag instead of
  774. **  their own functions
  775. */
  776.  
  777. #define isC(ch)     (isalnum((ch)) || (ch) == '_')
  778.  
  779. char * current_word (void)
  780. {
  781.     register char * str;
  782.     register int i,j;
  783.  
  784.     str = (char *)firstbuffer;
  785.  
  786.     i = Ep->column;
  787.     while ((i>0) && isC(Current[i]))
  788.     {           /*  goto beginning of word */
  789.     i--;
  790.     } /* while */
  791.     while ((Current[i]) && !isC(Current[i]))
  792.     {  /* skip spaces and other garbage */
  793.     i++;
  794.     } /* while */
  795.  
  796.     j = 0;
  797.     while (isC(Current[i]) && (j <= LINE_LENGTH))
  798.     {
  799.     str[j] = Current[i];                /* copy "word" into buffer */
  800.     j++;
  801.     i++;
  802.     } /* while */
  803.     str[j] = 0;
  804.  
  805.     return (str);
  806. } /* current_word */
  807.  
  808.  
  809. /******************************************************************************
  810. *****  ENDE smallspc.c
  811. ******************************************************************************/
  812.